

ENT.Type = "anim"
ENT.Base = "team_base"

ENT.PrintName		= ""
ENT.Author			= ""
ENT.Contact			= ""
ENT.Purpose			= ""
ENT.Instructions	= ""


//Max angles the sentry can hit, please only modify the number
ENT.MaxRotationX = math.cos( math.Deg2Rad( 60 ) )
ENT.MaxRotationY = math.cos( math.Deg2Rad( 30 ) ) //The actual limit is 15

//Maximum range
ENT.Range = 1200

//The sentry fires 3 bullets every 1 seconds, 2 damage each
ENT.BulletDamage = 2.0
ENT.BulletsPerRound = 3
ENT.CoolDownTime = 1


function ENT:LoadSettings()
    for k, v in pairs( NicanSettings.Sentry ) do
        self[ k ] = v
    end
end


//DO NOT CHANGE
ENT.EyeBonePos = 2


function ENT:InConeView( mypos, target )

    local TargetPos = target:EyePos() - Vector(0,0,15)
    
    self.AimDirection = (TargetPos - mypos):Normalize()
    
    local AngleDifference = self.AimDirection:Angle()  - self:GetAngles()
    
    local YawDif = math.cos( math.Deg2Rad( AngleDifference.y ) )
    local PitchDif = math.cos( math.Deg2Rad( AngleDifference.p ) )
    
    return YawDif > self.MaxRotationX && PitchDif > self.MaxRotationY && TargetPos:Distance(mypos) < self.Range
end



function ENT:SetPitch( value )
    if value < -15 then 
        value = -15
    elseif value > 15 then 
        value = 15
    else
        value = math.Round( value )
    end

    self:SetPoseParameter("aim_pitch", value  )
end

function ENT:SetYaw( value )
    if value < -60 then 
        value = 60
    elseif value > 60 then 
        value = 60
    else 
        value = math.Round( value )
    end
    
    self:SetPoseParameter("aim_yaw", value  )
end



